﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public DataSet QueryICC_WBBST(DataRow dwData, int option)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            string qty = "0";
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    break;
                case 2: 
                    or1.CommandText = "SELECT  1 AS BAID, WBBMANDANT AS MANDANT,WBBART AS ART,WBBVAR AS VAR,WBBFARBE AS COLOR,WBBLO AS LO,WBBLB AS LB,"
                    + "SUM(WBBISTKLG*0.001) AS QTY,0 AS QTYLOCKED,SUM(WBBISTKLG*0.001) AS QTYFREE, SUM(WBBSGEW*0.001) AS WBBSGEW, MAX(WBBSTKNR) AS STK FROM WBBST M  "
                            + " WHERE WBBMANDANT=:WBBMANDANT AND WBBART=:WBBART AND WBBFARBE=:WBBFARBE"
                            + " AND WBBISTKLG>0 AND (WBBLO='01' OR WBBLB='KC') "
                            + " GROUP BY WBBMANDANT,WBBART,WBBVAR,WBBFARBE,WBBLB,WBBLO ";
                    or1.Parameters.Add("WBBMANDANT", OracleType.NVarChar).Value = dwData["WBBMANDANT"].ToString();
                    or1.Parameters.Add("WBBART", OracleType.NVarChar).Value = dwData["WBBART"].ToString();
                    //or1.Parameters.Add("WBBVAR", OracleType.NVarChar).Value = dwData["WBBVAR"].ToString();
                    or1.Parameters.Add("WBBFARBE", OracleType.NVarChar).Value = dwData["WBBFARBE"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "ICC_WBBST";
            Return = Result;
            return Return;
        }
    }
}
